import os

from .nodes.text_input_node import TextInputNode
# 导入新的节点类
from .nodes.lora_stack import MultiLoraLoader

from .nodes.text_input_with_lora import MarvelousTextInputWithLoraLoader

from server import PromptServer
from aiohttp import web
from .core.database.connection import db_manager
from .service import character,handler,prompt_items,tags,task,translate

plugin_dir = os.path.dirname(__file__)
db_manager.initialize(plugin_dir)

def register_routes():
    app = PromptServer.instance.app
    app.add_routes(character.routes)
    app.add_routes(handler.routes)
    app.add_routes(prompt_items.routes)
    app.add_routes(tags.routes)
    app.add_routes(task.routes)
    app.add_routes(translate.routes)

# 注册所有节点类
NODE_CLASS_MAPPINGS = {
    "MarvelousText": TextInputNode,
    "MarvelousBox": MarvelousTextInputWithLoraLoader
}

NODE_DISPLAY_NAME_MAPPINGS = {
    "MarvelousText": "MarvelousText",
    "MarvelousBox": "MarvelousBox",
}

WEB_DIRECTORY = "./web"

__all__ = ["NODE_CLASS_MAPPINGS", "WEB_DIRECTORY", "NODE_DISPLAY_NAME_MAPPINGS"]

register_routes()